namespace FamilyJobsUI.DB
{
    using System;
    using System.Data.Entity;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Linq;

    public partial class FamilyJobsDB : DbContext
    {
        public FamilyJobsDB()
            : base("name=FamilyJobsDB")
        {
        }

        public virtual DbSet<T_PointTypes> T_PointTypes { get; set; }
        public virtual DbSet<T_UserPoints> T_UserPoints { get; set; }
        public virtual DbSet<T_Users> T_Users { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<T_PointTypes>()
                .HasMany(e => e.T_UserPoints)
                .WithRequired(e => e.T_PointTypes)
                .HasForeignKey(e => e.up_PointTypeID)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<T_Users>()
                .Property(e => e.user_Name)
                .IsUnicode(false);

            modelBuilder.Entity<T_Users>()
                .Property(e => e.user_Email)
                .IsFixedLength();

            modelBuilder.Entity<T_Users>()
                .HasMany(e => e.T_UserPoints)
                .WithRequired(e => e.T_Users)
                .HasForeignKey(e => e.up_UserID)
                .WillCascadeOnDelete(false);
        }
    }
}
